package com.ifonly.utils;

/**
 * @author ifonly
 * @version 1.0 2016-01-13 14:29
 * @since JDK 1.6
 */
public class AopUtils {
    public static final String CGLIB_CLASS_SEPARATOR = "$$";

    public static boolean isCglibClass(Class<?> clazz) {
        return clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR);
    }

    public static <T> Class<T> getCglibProxyTargetClass(Class<T> clazz) {
        String name = clazz.getName();
        name = name.substring(0, name.indexOf(CGLIB_CLASS_SEPARATOR));
        return ClassUtils.loadClass(name);
    }

}
